package pikes.ecma;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import pikes.ecma.Addition;

public class AdditionTestCase {

	private MockSyntaxTreeVisitor syntaxTreeVisitor = null;

	@Before
	public void setup() {
		syntaxTreeVisitor = new MockSyntaxTreeVisitor();
	}

	@Test
	public void add() throws Exception {
		MockIAdditiveExpression additiveExpression = new MockIAdditiveExpression();
		MockIMultiplicativeExpression multiplicativeExpression = new MockIMultiplicativeExpression();

		Addition add = new Addition(additiveExpression, multiplicativeExpression);
		add.visit(syntaxTreeVisitor);

		Assert.assertSame(syntaxTreeVisitor, additiveExpression.syntaxTreeVisitor);
		Assert.assertEquals("+", syntaxTreeVisitor.binaryOperator);
		Assert.assertSame(syntaxTreeVisitor, multiplicativeExpression.syntaxTreeVisitor);
	}

	@Test
	public void equals() throws Exception {

		Addition add1 = new Addition("a", "b");
		Addition add2 = new Addition("a", "b");

		Assert.assertEquals(add1, add2);
	}
}
